<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="org.slf4j.Logger" %>
<%@ page import="org.slf4j.LoggerFactory" %>
<%@ page import="com.tencent.albert.weixin.driver.utils.JspLogger" %>
<%@ page import="java.util.Map" %>
<%@ page import="org.apache.commons.collections.MapUtils" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="com.tencent.albert.weixin.driver.utils.WeixinUtil" %>
<%@ page import="com.tencent.albert.weixin.driver.bean.WxUserInfo" %>
<%--
  Created by IntelliJ IDEA.
  User: albertzhu
  Date: 15/2/15
  Time: 下午2:56
  To change this template use File | Settings | File Templates.
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%
//    java.util.Enumeration names = request.getHeaderNames();
//    while (names.hasMoreElements()) {
//        String name = (String) names.nextElement();
//        System.out.println("read header " + name + ":" + request.getHeader(name));
//    }
    Map<String,String[]> params = request.getParameterMap();
    for (Map.Entry<String,String[]> entry : params.entrySet()) {
        System.out.println("param key:"+entry.getKey()+" value:"+ Arrays.toString(entry.getValue()));
    }
    String code = request.getParameter("code");
    String state = request.getParameter("state");
    if (!StringUtils.isBlank(code)) {
        WxUserInfo info = WeixinUtil.getWxUserInfo(code);
        out.println(info);
    } else {
        String ua = request.getHeader("user-agent");
        JspLogger.info("oauth",
                "receive null code oath request from "+request.getHeader("x-real-ip")
                        +":"+request.getRequestURL()+"?"+request.getQueryString()+" ua:"+ua,null);
    }

%>
